const privatation = (action, property) => {
  if (/^[_]+/.test(property)) {
    throw new Error(`内部属性，禁止执行 ${action}: ${property}`)
  } else {
    console.log(`外部属性，允许执行 ${action}: ${property}`)
  }
}

const targetObj = {
  name: 'henry',
  age: 18,
  _gender: '性别保密'
}
const proxy = new Proxy(targetObj, {
  get(target, property) {
    privatation('get', property)
    return target[property]
  },
  set(target, property, value) {
    privatation('set', property)
    target[property] = value
    return true
  },
  deleteProperty(target, property) {
    privatation('delete', property)
    delete target[property]
    return true
  }
})

console.log(proxy.name) //=> henry
// console.log(proxy._gender) //=> Uncaught Error: 内部属性，禁止执行 get: _gender

console.log('===')
delete proxy.age
// delete proxy._gender //=> Error: 内部属性，禁止执行 delete: _gender
console.log('targetObj', targetObj) //=> { name: 'henry', _gender: '性别保密' }
